package main;

public class Coord implements Cloneable {
	
	public int x;
	public int y;
	
	public Coord(int x, int y) {
		this.x=x;
		this.y=y;
	}
	
	public String toString() {
		return "("+ x +", "+ y +")";
	}
	
	@Override
	public boolean equals(Object o) {
		Coord oo = (Coord) o;
		return oo.x == x && oo.y == y;
	}
	
	public double getTrajectory(Coord c) {
		int xx = c.x-x;
		int yy = c.y-y;
		return (double)yy/(double)xx;
	}
	
	public Coord clone() {
		return new Coord(x, y);
	}

	public double distanceTo(Coord c) {
		int xx = c.x-x;
		int yy = c.y-y;
		return Math.sqrt(xx*xx+yy*yy);
	}

	public double angle(Coord target) {
		double xx = target.x - x;
		double yy = target.y - y;
		
		if (xx >= 0 && yy >= 0) {
			return Math.atan(yy/xx);
		} else if (xx < 0 && yy >= 0) {
			return Math.PI+Math.atan(yy/xx);
			
		} else if (xx < 0 && yy < 0) {
			return Math.PI+Math.atan(yy/xx);
			
		} else {
			return Math.atan(yy/xx);
		}
	}
	
	public void convert(int xfactor, int yfactor) {
		x = x*xfactor+xfactor/2;
		y = y*yfactor+yfactor/2;
	}
}
